using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;
using static TMPro.SpriteAssetUtilities.TexturePacker_JsonArray;


namespace AsterroidX
{

    public class ScreenHelper 
    {
      public static  Vector3 LeftBottomScreenPos = new Vector2(-17.8f, -10);

        public static Vector3 RightTopScreenPos = new Vector2(17.8f, 10);

        public static float ScreenWordWidth => RightTopScreenPos.x - LeftBottomScreenPos.x;

        public static float ScreenWordHeight => RightTopScreenPos.y - LeftBottomScreenPos.y;
        public static bool RepeatScreen(Transform transform, float offsetX, float offsetY)
        {
           

            if (transform.position.x < LeftBottomScreenPos.x - offsetX)
            {
                transform.Position(new Vector3
                    (transform.position.x + ScreenWordWidth + offsetX * 2, transform.position.y, transform.position.z));
                return true;
            }
            else if (transform.position.x > RightTopScreenPos.x + offsetX)
            {
                transform.Position(new Vector3
                    (transform.position.x - ScreenWordWidth - offsetX * 2, transform.position.y, transform.position.z));
                return true;
            }
            else if (transform.position.y > RightTopScreenPos.y + offsetY)
            {
                transform.Position(new Vector3
                    (transform.position.x, transform.position.y - ScreenWordHeight - offsetY * 2, transform.position.z));
                return true;
            }
            else if (transform.position.y < LeftBottomScreenPos.y - offsetY)
            {
                transform.Position(new Vector3
                    (transform.position.x, transform.position.y + ScreenWordHeight + offsetY * 2, transform.position.z));
                return true;
            }
            return false;
        }

        public static bool OutScreen(Transform transform, float offsetX, float offsetY)
        {


            if (transform.position.x < LeftBottomScreenPos.x - offsetX)
            {
                return true;
            }
            else if (transform.position.x > RightTopScreenPos.x + offsetX)
            {
                return true;
            }
            else if (transform.position.y > RightTopScreenPos.y + offsetY)
            {
                return true;
            }
            else if (transform.position.y < LeftBottomScreenPos.y - offsetY)
            {
                return true;
            }
            return false;
        }

    }
}

